<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    // 给定两个字符串形式的非负整数 num1 和num2 ，计算它们的和并同样以字符串形式返回。

    var addStrings = function (num1, num2) {
        let i = num1 - 1
        let j = num2 - 1
        let add = 0
        let newarr = []
        while (i >= 0 || j >= 0 || add != 0) {
            let x = i >= 0 ? num1.charAt(i) - '0' : 0
            let y = j >= 0 ? num2.charAt(j) - '0' : 0
            let res = x + y + add
            arr.push(res % 10)
            add = Math.floor(res / 10)
            i -= 1
            j -= 1
        }
        return arr.reverse().join('')
    };
</script>